<?php
require_once("db/config.php");
 header("Content-Type:text/html;charset=utf-8");
 session_start();
// echo session_id();
 //首先判断Cookie是否有记住用户信息
 if (isset($_COOKIE['username'])) {
     $_SESSION['username']=$_COOKIE['username'];
     $_SESSION['islogin']=1;
 }

$sid=session_id();
$sql="select * from message where sid='$sid'";
$set=mysqli_query($con, $sql);
 //获取所有行数据
$row = mysqli_fetch_array($set);
$flag= mysqli_num_rows($set);
// echo $flag;

 if (isset($_SESSION['islogin']) || $flag==1) {
     //已经登录
     if (isset($row['user'])) {
         echo $row['user'].":你好，欢迎进入个人中心！<br/>";
     } else {
         echo $_SESSION['username'].":你好，欢迎进入个人中心！<br/>";
     }
     
     echo "<a href='logout.php'>注销</a>";
 } else { //未登录
     echo "你还未登录，请<a href='login.php'>登录</a>";
 }
?> 